<!-- components/ProfileCard.vue -->
<script setup lang="ts">
import { myMatchmakerAdd } from '@/services/matchmaker/myMatchmakerAdd'
import { ref } from 'vue'
// 接收红娘团队信息
const flag = ref(false)
const props = defineProps({
  id: String,
  image: String,
  name: String,
  description: String,
})

const connect = () => {
  console.log(props.id)
  let user_id = uni.getStorageSync('userInfo').id
  myMatchmakerAdd({ u_id: user_id, m_id: props.id }).then((res) => {
    if (res.code === 200) {
      flag.value = true
      uni.showToast({
        title: '添加红娘成功',
        icon: 'success',
        duration: 2000,
      })
    }
  })
}
</script>

<template>
  <view class="profile-card">
    <image :src="props.image" class="profile-image"></image>
    <view class="profile-info">
      <view class="profile-name">婚恋顾问@{{ props.name }}</view>
      <view class="profile-description">{{ props.description }}婚恋顾问</view>
      <button class="profile-button" @click="connect">+ 找她牵线</button>
    </view>
  </view>
  <!-- <view class="spacer">添加红娘成功</view> -->
</template>

<style lang="scss">
.profile-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
  -moz-box-shadow: 2px #ec7496;
  -webkit-box-shadow: 2px #ec7496;
  box-shadow: 4px 4px 9px -2px #ec7496;
}

.profile-image {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

.profile-info {
  margin-top: 8px;

  .profile-button {
    width: 250rpx;
    background: #ec7496;
  }
}

.profile-name {
  font-size: 30rpx;
  font-weight: 500;
  color: black;
}

.profile-description {
  margin: 8px 0;
  font-size: 26rpx;
  font-weight: 300;
}

button {
  background: #ec7496;
  color: white;
  border: none;
  border-radius: 3rem; // 设置为25px使按钮两端变为圆形
  font-size: 26rpx;
  cursor: pointer;
  // transition: background 0.3s ease;
}

/* 媒体查询适配平板 */
@media (min-width: 768px) and (max-width: 1024px) {
  .profile-container {
    justify-content: space-around;
  }

  .profile-card {
    flex: 1 1 calc(50% - 16rpx);
    /* Each card takes up half the width, minus some margin */
  }
}

.spacer {
  width: 300rpx;
  height: 100rpx;
  text-align: center;
  line-height: 100rpx;
  position: fixed;
  background: #000;
  color: #fff;
  border-radius: 3rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 1;
  animation: spacer 1s;
}

@keyframes spacer {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}
</style>
